layui.use(['layer', 'form', 'admin', 'laydate', 'HttpRequest', 'address'], function () {
    var $ = layui.jquery;
    var HttpRequest = layui.HttpRequest;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;
    let address = layui.address;

    //获取信息详情填充表单
    var studentId = Feng.getUrlParam("studentId");
    var request = new HttpRequest(Feng.ctxPath + "/student/detail?id=" + studentId, 'get');
    var result = request.start();
    result.data.birthday=result.data.birthday.replace('00:00:00','').trim();
    form.val('studentForm', result.data);
    new address('address', form,result.data.addressAreaCode);
    new address('register', form,result.data.registeredAreaCode);
    new address('house', form,result.data.houseAreacCode);

    // 渲染时间选择框
    laydate.render({
        elem: '#birthday'
    });

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        console.info(data);
        data.field['id'] = studentId;
        var request = new HttpRequest(Feng.ctxPath + "/student/edit", 'post', function (data) {
            admin.closeThisDialog();
            Feng.success("修改成功！");
            admin.putTempData('formOk', true);
        }, function (data) {
            Feng.error("修改失败！" + data.message);
        })
        request.set(data.field);
        request.start(true);
        return false;
    });
});
